package net.dnw.practicesummary.mvp.base;

import com.google.gson.Gson;

import net.dnw.practicesummary.mvp.net.RetrofitServiceManager;

import okhttp3.RequestBody;
import retrofit2.Retrofit;

/**
 * Created by Administrator on 2019/3/11 0011.
 */

public abstract class BaseModel <T> {

    protected final Retrofit retrofit;

    protected T request;

    public BaseModel() {
        retrofit = RetrofitServiceManager.getInstance().getRetrofit();
        request = createService();
    }

    protected RequestBody getRequestBody(Object obj) {
        String route = new Gson().toJson(obj);
        RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), route);
        return body;
    }


    public abstract void onDestory();

    public abstract T createService();

}
